<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/static/crm/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/crm/css/public.css" media="all">
    <title>Document</title>
</head>

<body>
    <form class="layui-form layui-form-pane layui-container" lay-filter="form" action="">
                <div style="margin: 40px 20px 40px 20px">
                    <div class="layui-form-item">
                        <div class="layui-row ">
                            {volist name = '$list' id = 'list' }
                            <div class="layui-inline">
                                <label class="layui-form-label">商机名称:</label>
                                <div class="layui-input-inline">
                                    <input value="{$list.name}" id="name" type="text" name="name" autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">客户名称:</label>
                                <div class="layui-input-inline">
                                   <select name="client_id" id="client_id" lay-verify="">
                                        {volist name = '$aa' id = 'aa'}
                                        <option value="{$aa.Ourclients.id}" {if $list.client_id==$aa.Ourclients.id } selected {/if}>{$aa.Ourclients.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            
                            <div class="layui-inline">
                                <label class="layui-form-label">客户预算:</label>
                                <div class="layui-input-inline">
                                    <input value="{$list.money}" id="money" type="text" name="money" autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">备注:</label>
                                <div class="layui-input-inline">
                                    <input value="{$list.remark}" id="remark" type="text" name="remark" autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline"">
                                <label class=" layui-form-label">预计成交:</label>
                                <div class="layui-input-inline">
                                    <input value="{$list.predict_time}" type="text" name="predict_time" class="layui-input" id="test" placeholder="">
                                </div>
                            </div>

                            <div class="layui-inline"">
                                <label class=" layui-form-label">下次跟进:</label>
                                <div class="layui-input-inline">
                                    <input value="{$list.follow_time}" type="text" name="follow_time" class="layui-input" id="test2" placeholder="">
                                </div>
                            </div>
                            {/volist}

                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
    </form>
</body>

</html>
<script src="/static/crm/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'laydate', 'jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.jquery;

        laydate.render({
            elem: '#test'
        });
        laydate.render({
            elem: '#test2'
        });

        form.on('submit(formDemo)', function (data) {
            $.ajax({
                url: 'amend',
                type: 'post',
                dataType: 'json',
                data: data.field,
                success: function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg,{
                            time:1500,
                            end: function(){
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                            }
                        });
                        
                    } else if (data.code == 0){
                        layer.msg(data.msg);
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    });
</script>